﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;

namespace SqlMeth
{
    /// <summary>
    /// Class to load app configuration settings
    /// </summary>
    public class ConfigSettings
    {
        public string Avoid { get; set; }
        public string SprocNameMask { get; set; }
        public string ActionMask { get; set; }
        public string ViewPrefix { get; set; }
        public SqlMetalSettings MetalSettings { get; set; }

        /// <summary>
        /// Parses an XML file to load all the settings for this app
        /// </summary>
        /// <param name="reader">XML file that holds the configuration settings</param>
        /// <returns>A ConfigLoader object loaded with the configuration settings found</returns>
        public static ConfigSettings ParseFromFile(StreamReader reader)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(ConfigSettings));
            ConfigSettings configuration = (ConfigSettings)serializer.Deserialize(reader);

            return configuration;
        }
    }

    /// <summary>
    /// Class to load the SQLMetal settings
    /// </summary>
    public class SqlMetalSettings
    {
        /// <summary>
        /// Namespace of the DBML file
        /// </summary>
        public string DbmlNamespace { get; set; }

        /// <summary>
        /// Type of output to be generated. Values are: "DBML" and "Code"
        /// </summary>
        public string OutputType { get; set; }

        /// <summary>
        /// Path to SqlMetal executable
        /// </summary>
        public string Path { get; set; }

        /// <summary>
        /// Set to "true" to extract database views
        /// </summary>
        public bool Views { get; set; }

        /// <summary>
        /// Set to "true" to extract database functions
        /// </summary>
        public bool Functions { get; set; }

        /// <summary>
        /// Set to "true" to extract database stored procedures
        /// </summary>
        public bool StoredProcedures { get; set; }

        /// <summary>
        /// Set path to output the DBML file
        /// </summary>
        public string DbmlPath { get; set; }

        /// <summary>
        /// Set output language. Options include: "vb" and "csharp"
        /// </summary>
        public string Language { get; set; }
    }
}
